<script src="https://cdn.bootcss.com/vee-validate/2.0.0-rc.18/vee-validate.min.js"></script>
<script src="https://cdn.bootcss.com/vee-validate/2.0.0-rc.18/locale/zh_CN.js"></script>
<style>
    .is-danger {
        color: red
    }
</style>
<div id="app">
    <div class="form-group">
        <label>invoice</label>
        <input type="text" class="form-control" v-model="invoice" />
    </div>

    <div class="form-group">
        <label>收入</label>
        <input type="number" step=0.01 class="form-control" v-model="in_come"/>
    </div>

    <div class="form-group">
        <label>支出</label>
        <input type="number" step=0.01 class="form-control" v-model="total_fee"/>
    </div>

    <div class="form-group">
        <label>费用</label>
        <input type="number" step=0.01 class="form-control" v-model="fee"/>
    </div>

    <button class="btn btn-success" @click="update">提交</button>
    <div>
        <script>
            new Vue({
                el: "#app",
                data: {
                    invoice: "",
                    in_come: "",
                    total_fee: "",
                    fee: "",
                    id:<?php echo $this->params['id'];?>
                },
                methods: {
                    update:function(){
                        if (!this.invoice){
                            layer.alert("invoice还未输入");return false;
                        }
                        var that = this;
                        layer.confirm('确认提交',{},function(){
                            var data = {
                                invoice:that.invoice,
                                in_come:that.in_come,
                                total_fee:that.total_fee,
                                fee:that.fee,
                                id:that.id
                            }
                            $.post('/table/split_income_insert',data,function(res){
                                if (res.code==1) {
                                    layer.alert(res.msg);setTimeout(() => {
                                        window.location.reload();
                                    }, 1000);
                                }else {
                                    layer.alert(res.msg);
                                }
                            },'json')
                        })
                    }
                }
            })
        </script>